package com.eternal.log.adapter;

import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import android.view.ViewGroup;
import android.widget.TextView;

import com.eternal.base.database.entity.Log;
import com.eternal.log.R;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class LogCHeaderHolder extends LogCHolder {
    private TextView month;

    public LogCHeaderHolder(@NonNull ViewGroup parent, @LayoutRes int layout) {
        super(parent, layout);
        month = itemView.findViewById(R.id.tv_month);
    }

    public LogCHeaderHolder(@NonNull ViewGroup parent) {
        this(parent, R.layout.log_item_header);
    }

    @Override
    public Date init(Log log, long start, boolean isDegree) {
        Date result = super.init(log, start, isDegree);
        SimpleDateFormat format = new SimpleDateFormat("yyyy MMM dd", Locale.ENGLISH);
        month.setText(format.format(result).toUpperCase());
        return result;
    }
}
